package patterns.nullobject;

/**
 * Created by lenovo on 2016/12/9 0009.
 * 通过工厂类来调用不同的customer对象，演示空对象操作。
 */
public class NullPatternDemo {
    public static void main(String[] args){
        AbstractCustomer customer1 = CustomerFactory.getCustomer("robert");
        AbstractCustomer customer2 = CustomerFactory.getCustomer("john");
        AbstractCustomer customer3 = CustomerFactory.getCustomer("joe");
        //因为没有这个人名的数据存在，所以创建的对象是NUllcustomer对象，而不是null
        AbstractCustomer customer4 = CustomerFactory.getCustomer("laura");

        System.out.println("Customers:");
        System.out.println(customer1.getName());
        System.out.println(customer2.getName());
        System.out.println(customer3.getName());
        System.out.println(customer4.getName());
    }
}
